Add a failing test before fixing #1222

Akinori MUSHA 9 years ago
parent
commit
f378922c25
1 changed files with 23 additions and 2 deletions
  1. 23 2
      spec/models/agents/event_formatting_agent_spec.rb

+ 23 - 2
spec/models/agents/event_formatting_agent_spec.rb

@@ -40,6 +40,21 @@ describe Agents::EventFormattingAgent do
40 40
         },
41 41
         :conditions => "someothervalue"
42 42
     }
43
+
44
+    @event2 = Event.new
45
+    @event2.agent = agents(:jane_weather_agent)
46
+    @event2.created_at = Time.now
47
+    @event2.payload = {
48
+        :content => {
49
+            :text => "Some Lorem Ipsum 2",
50
+            :name => "somevalue2",
51
+        },
52
+        :date => {
53
+            :epoch => "1357966800",
54
+            :pretty => "00:00 AM EST on January 12, 2015"
55
+        },
56
+        :conditions => "someothervalue2"
57
+    }
43 58
   end
44 59
 
45 60
   describe "#receive" do
@@ -63,8 +78,14 @@ describe Agents::EventFormattingAgent do
63 78
     end
64 79
 
65 80
     it "should handle matchers and Liquid templating in instructions" do
66
-      @checker.receive([@event])
67
-      expect(Event.last.payload[:subject]).to eq("Weather looks like someothervalue according to the forecast at 10:00 PM EST")
81
+      expect {
82
+        @checker.receive([@event, @event2])
83
+      }.to change { Event.count }.by(2)
84
+
85
+      formatted_event1, formatted_event2 = Event.last(2)
86
+
87
+      expect(formatted_event1.payload[:subject]).to eq("Weather looks like someothervalue according to the forecast at 10:00 PM EST")
88
+      expect(formatted_event2.payload[:subject]).to eq("Weather looks like someothervalue2 according to the forecast at 00:00 AM EST")
68 89
     end
69 90
 
70 91
     it "should allow escaping" do